/*
 *  Copyright 2008 Danny Lagrouw
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License. 
 */
package org.bastion.example.domain;

import java.util.ArrayList;
import java.util.List;

import org.bastion.domain.ExampleDomainObject;

/**
 * @author Danny Lagrouw
 *
 */
public class Vehicle extends ExampleDomainObject {

	private static final long serialVersionUID = 1L;

	private String registration;
	
	private String model;
	
	private VehicleType vehicleType;

	private List<Reservation> reservations = new ArrayList<Reservation>();
	
	private List<Rental> rentals = new ArrayList<Rental>();
	
	private Vehicle() {
		super(false);
	}
	
	public Vehicle(String registration, String model, VehicleType vehicleType) {
		super();
		this.registration = registration;
		this.model = model;
		this.vehicleType = vehicleType;
	}

	public Amount getQuote(Period period) {
		return vehicleType.getQuote(period);
	}

	public String getRegistration() {
		return registration;
	}

	public String getModel() {
		return model;
	}

	public VehicleType getVehicleType() {
		return vehicleType;
	}
	
	public Reservation reserve(Period period, Client client) {
		Reservation reservation = new Reservation(period, client, this);
		return reservation;
	}

	protected void addReservation(Reservation reservation) {
		reservations.add(reservation);
	}

	protected void addRental(Rental rental) {
		rentals.add(rental);
	}

	@Override
	public String toString() {
		return super.toString() + "/registration=" + registration + "/model=" + model + "/vehicletype=" + vehicleType.getDescription();
	}
	
}
